const app = getApp()

Page({
  data: {
    availableModels: [],
    enabledModelIds: [],
    elderlyModeEnabled: false
  },

  onLoad() {
    this.updateData()
  },
  
  onShow() {
    this.updateData()
  },
  
  // 更新页面数据
  updateData() {
    const globalData = app.globalData
    
    this.setData({
      availableModels: globalData.availableModels,
      enabledModelIds: globalData.enabledModelIds,
      elderlyModeEnabled: globalData.elderlyModeEnabled
    })
  },
  
  // 选择模型并开始新对话
  selectModel(e) {
    const { modelId } = e.currentTarget.dataset
    
    // 创建新会话
    app.createNewSession(modelId)
    
    // 跳转到聊天页面
    wx.redirectTo({
      url: '/pages/chat/chat'
    })
  },
  
  // 跳转到设置页面
  goToSettings() {
    wx.redirectTo({
      url: '/pages/settings/settings'
    })
  }
}) 